using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Web.Configuration;

public partial class Test : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string sql_script =
@"
SELECT * from Participants";
        string sql_script2 = "select * from Answers";
        string sql_script3 = "select max(id) as max from Participants";
        IDbConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["SurveyConnectionString"].ConnectionString);
        using (conn)
        {
            conn.Open();
            IDbCommand cmd = conn.CreateCommand();
            cmd.CommandText = sql_script;
            IDataReader dr = cmd.ExecuteReader();

            GridView1.DataSource = dr;
            GridView1.DataBind();
            dr.Close();
            cmd.CommandText = sql_script2;
            IDataReader dr2 = cmd.ExecuteReader();

            GridView2.DataSource = dr2;
            GridView2.DataBind();
            dr2.Close();

            cmd.CommandText = sql_script3;
            SqlDataReader dr3 = (SqlDataReader)cmd.ExecuteReader();
            dr3.Read();
            lbNewestRecord.Text = dr3["max"].ToString();
            
        }
        Participant participant = (Participant)Session[FormContract.USER_REF];
        lbParticipant.Text = Convert.ToInt32(participant.ParticipantID).ToString();
        lbSessionTimeout.Text = Session.Timeout.ToString();
        
    }
}
